<template>
	<view>
		<view>
			<view style="margin: 30rpx;">
				<u-button class="custom-style" style="margin-left: 20rpx;" type="primary" shape="circle" text="全部" @click="select()"></u-button>
			</view>
			<view style="margin: 30rpx;">
				<u-button class="custom-style" style="margin-left: 20rpx;" type="primary" shape="circle" text="已完成" @click="finish()"></u-button>
			</view>
			<view style="margin: 30rpx;">
				<u-button class="custom-style" style="margin-left: 20rpx;" type="primary" shape="circle" text="未完成" @click="undone()"></u-button>
			</view>
		</view>
		<!-- <template>
			<u-subsection :list="list" :current="curNow"  @change="sectionChange"></u-subsection>
		</template> -->
		
		<view v-for="(item,index) in InfoList" :key="index">
			<uni-card style="float: left; width: 650rpx;" @click="info(item.aid)">
				
				<view style="font-size: 14px;color:#303133;" >
					{{item.aname}}
				</view><br>
				<view style="font-size: 14px;color:#303133;" >
					被考核人：{{item.name}}
				</view><br>
				<view style="font-size: 14px;color:#303133;" >
					考核周期：{{item.cycle}}
				</view><br>
				<view style="font-size: 14px;color:#303133;" >
					考核时间：{{aa(item.time)}}
				</view><br>
				<view>
					<view v-if="item.status == 1">
						<view style="color: #18BC37;">考核进度：已完成</view>
					</view>
					<view v-else>
						<view style="color: #E43D33;">考核进度：未完成</view>
					</view>
				</view>
				
			</uni-card>
		</view>	
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				aid:undefined,
				InfoList:{
					aid:'',
					aname:'',
					name:'',
					cycle:'',
					status:'',
					time:''
				},
				eid:'',
				user:{},
				list: ['全部', '已完成', '未完成'],
				// 或者如下，也可以配置keyName参数修改对象键名
				// list: [{name: '未付款'}, {name: '待评价'}, {name: '已付款'}],
				curNow: 0
			}
		},
		onLoad() {
			this.session()
			this.eid=this.user.eid
			console.log(this.eid)
		},
		mounted(){
			this.select()
		},
		methods: {
			aa(date){
							const dateTime = new Date(date)
							const YY = dateTime.getFullYear()
							const MM =
								dateTime.getMonth() + 1 < 10 ? '0' + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1
							const DD =
								dateTime.getDate() < 10 ? '0' + dateTime.getDate() : dateTime.getDate()
							const hh =
								dateTime.getHours() < 10 ? '0' + dateTime.getHours() : dateTime.getHours()
							const mm =
								dateTime.getMinutes() < 10 ? '0' + dateTime.getMinutes() : dateTime.getMinutes()
							const ss =
								dateTime.getSeconds() < 10 ? '0' + dateTime.getSeconds() : dateTime.getSeconds()
							return `${YY}-${MM}-${DD}`
						},
			select(){
				uni.request({
					url:'http://localhost:9525/performance/achievements/select?eid=' + this.eid,
					method:'GET',
					success: (res) => {
						this.InfoList=res.data.data.list
					}
					
				})
			},
			finish(){
				uni.request({
					url:'http://localhost:9525/performance/achievements/finish?eid=' + this.eid, 
					method:'GET',
					success: (res) => {
						this.InfoList=res.data.data.list
					}
					
				})
			},
			undone(){
				uni.request({
					url:'http://localhost:9525/performance/achievements/undone?eid=' + this.eid,
					method:'GET',
					success: (res) => {
						this.InfoList=res.data.data.list
					}
					
				})
			},
			info(aid){
				uni.navigateTo({
					url:"./info?aid="+aid
				})
			},
			session(){
				this.user=uni.getStorageSync('user')
				console.log(this.user)
			},
			sectionChange(index) {
				this.curNow = index;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.custom-style {
			color: #ffffff;
			width: 200rpx;
			float: left;
			
			
		}
</style>
